package objs;

import service.Play;

import java.awt.*;

import static service.Play.img_Me_Destory3;

public class Enemyobj extends Pojo{
    public Enemyobj() { }

    public Enemyobj(Image image, int x, int y, int width, int height, double speed, Play frame) {
        super(image, x, y, width, height, speed, frame);
    }

    @Override
    public void paintSelf(Graphics gImage) {
        y+=speed;
        gImage.drawImage(image,x,y,width,height,null);

        for(int i=0;i<Play.bulletobjList.size();i++){
            if(this.getRec().intersects(Play.bulletobjList.get(i).getRec())){
//                bulletobj.setX(bulletobj.getX()-200);
//                bulletobj.setY(bulletobj.getY()+200);
//                this.setX(this.getX()-200);
//                this.setY(this.getY()+200);
                gImage.drawImage(Play.img_Enemy_Down1,this.getX(),this.getY(),69,95,null);
                gImage.drawImage(Play.img_Enemy_Down2,this.getX(),this.getY(),69,95,null);
                gImage.drawImage(Play.img_Enemy_Down3,this.getX(),this.getY(),69,95,null);
                gImage.drawImage(Play.img_Enemy_Down4,this.getX(),this.getY(),69,95,null);

                Play.removeList.add(Play.bulletobjList.get(i));
                Play.removeList.add(this);
                Play.bulletobjList.remove(Play.bulletobjList.get(i));
                Play.enemyobjList.remove(this);
                Play.score++;
            }
        }

        if(this.getRec().intersects(this.frame.meobj.getRec())){
            Play.state=3;
        }
        if(y>=800){
            Play.enemyobjList.remove(this);
            Play.removeList.add(this);
        }
    }
}
